#ifndef MYSERIAL_H
#define MYSERIAL_H

#include <QObject>
#include <qserialport.h>
#include <qserialportinfo.h>
#include <qdebug.h>
#include <qthread.h>
#include <qmessagebox.h>
#include <qtimer.h>
#include <protocol.h>
#include <QSemaphore>
#include <qfile.h>


extern QSemaphore sem_process;

class myserial : public QObject
{
    Q_OBJECT
public:
    explicit myserial(QObject *parent = nullptr);
    ~myserial();

signals:
    void disPortInfo(QList<QSerialPortInfo> info);
    void change_pbopen(QString tex);
    void process_read(QByteArray data);
    void err(QString);
    void dismsg(QString);

public slots:
    bool openport(QString name);
    void get_available_port();
    void tuichu();
    void writedata(QByteArray);
    void readdata();
    void timeout();

public:
    QSerialPort* port;
private:

    QList<QSerialPortInfo> portlist;
    QTimer* timer;
    QByteArray dat;
    QString recvdata;
    unsigned char buf[2048];
};

#endif // MYSERIAL_H
